﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data;
using System.Data.SqlClient;

namespace DAL
{
    /// <summary>
    /// Summary description for DALichSuCuocGoi
    /// </summary>
    public class DACauHoiFAQ : DbObject
    {
        public SqlConnection connec;
        public DACauHoiFAQ(SqlConnection Connection)
        {
            connec = Connection;
            //
            // TODO: Add constructor logic here
            //
        }

        public DataSet load_cau_hoi_faq(string ip_str_noidung_cauhoi, string ip_str_meta_tags)
        {
            DataSet op_ds_hist_call = new DataSet();
            SqlParameter[] parameters =  {	
                                             new SqlParameter("@NoiDungCauHoi", SqlDbType.NVarChar, 200)
                                             ,new SqlParameter("@MetaTag", SqlDbType.NVarChar, 200)
										 };
            // set the 0values
            parameters[0].Value = ip_str_noidung_cauhoi;
            parameters[1].Value = ip_str_meta_tags;
            // create the parameter
            op_ds_hist_call = RunProcedure("pr_TB_CauHoiFAQ_LoadDSCauHoi", parameters, "TB_LichSuCuocGoi", connec);
            return op_ds_hist_call;
        }
        public DataSet load_cau_hoi_faq_nguoidung(int ip_i_noidung_cauhoi)
        {
            DataSet op_ds_hist_call = new DataSet();
            SqlParameter[] parameters =  {	
                                             new SqlParameter("@NguoiDungId", SqlDbType.NVarChar, 200)
										 };
            // set the 0values
            parameters[0].Value = ip_i_noidung_cauhoi;
            // create the parameter
            op_ds_hist_call = RunProcedure("pr_TB_CauHoiFAQ_LoadDSCauHoiNguoiDung", parameters, "TB_LichSuCuocGoi", connec);
            return op_ds_hist_call;
        }
        public int update_lich_su_goi()
        {
            int intResult = 0;
            SqlParameter[] parameters =  {	
                                             new SqlParameter("@HocVienId", SqlDbType.Int,4)
                                             ,new SqlParameter("@LevelId", SqlDbType.Int,4)
                                             ,new SqlParameter("@CallId", SqlDbType.VarChar,50)
                                             ,new SqlParameter("@AgentCode", SqlDbType.VarChar,50)
                                             ,new SqlParameter("@MobilePhone", SqlDbType.VarChar,20)
                                             ,new SqlParameter("@StartTime", SqlDbType.DateTime)
                                             ,new SqlParameter("@EndTime", SqlDbType.DateTime)
                                             ,new SqlParameter("@datetime_respond", SqlDbType.DateTime)
                                             ,new SqlParameter("@StationId", SqlDbType.Int,4)
                                             ,new SqlParameter("@LinkDownRecord", SqlDbType.NVarChar,1000)
                                             ,new SqlParameter("@Duration", SqlDbType.Decimal)
                                             ,new SqlParameter("@NoiDungCuocGoi", SqlDbType.NVarChar,1000)
                                             ,new SqlParameter("@error_code", SqlDbType.Int,2)
                                             ,new SqlParameter("@error_desc", SqlDbType.VarChar,50)
                                             ,new SqlParameter("@status", SqlDbType.Int,2)
                                             ,new SqlParameter("@ringtime", SqlDbType.Decimal)
										 };            
            // set the values
            //parameters[0].Value = IntHocVienId;
            //parameters[1].Value = IntLevelId;
            //parameters[2].Value = data.call_id;
            //parameters[3].Value = data.agent_code;
            //parameters[4].Value = data.mobile_phone;
            //parameters[5].Value = datStartTime;
            //parameters[6].Value = datEndTime;
            //parameters[7].Value = datRespond_time;
            //parameters[8].Value = data.station_id;
            //parameters[9].Value = data.link_down_record;
            //parameters[10].Value = data.duration;
            //parameters[11].Value = StrNoiDungCuocGoi;
            //parameters[12].Value = data.error_code;
            //parameters[13].Value = data.error_desc;
            //parameters[14].Value = data.status;
            //parameters[15].Value = data.ringtime;
            try
            {
                RunProcedure("sp_TB_LichSuGoi_update_lich_su_goi", parameters, out intResult, connec);
            }
            catch (Exception v_e)
            {
                //Utilities.WriteToLog(v_e);
            }
            return 1;
        }
        public int insert_cau_hoi(string strNoiDungCauHoi, string strMetaTags, string strKieuCauHoi, int intUserID)
        {
            int intResult = 0;
            SqlParameter[] parameters =  {	
                                             new SqlParameter("@NoiDungCauHoi", SqlDbType.NVarChar,1500)
                                             ,new SqlParameter("@MetaTag", SqlDbType.NVarChar,450)
                                             ,new SqlParameter("@NguoiDungId", SqlDbType.Int,4)
                                             ,new SqlParameter("@LoaiCauHoi", SqlDbType.VarChar,20)
										 };

            // set the values
            parameters[0].Value = strNoiDungCauHoi;
            parameters[1].Value = strMetaTags;
            parameters[2].Value = intUserID;
            parameters[3].Value = strKieuCauHoi;
            try
            {
                RunProcedure("sp_TB_CauHoiFAQ_insert_cau_hoi", parameters, out intResult, connec);
            }
            catch (Exception)
            {
                //Utilities.WriteToLog(v_e);
            }
            return 1;
        }
    }
}